using System;

namespace Aks.Deployment.SharePoint.Data
{
	/// <summary>
	/// Represents a boolean CAML value node.
	/// </summary>
	internal class CamlBooleanValue : CamlValue<bool>
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="CamlBooleanValue"/> class.
		/// </summary>
		/// <param name="value">The value.</param>
		public CamlBooleanValue(bool value) : base(value)
		{}


		/// <summary>
		/// Gets the type of the CAML value.
		/// </summary>
		/// <value>The type of the value.</value>
		protected override string CamlType
		{
			get { return "Boolean"; }
		}


		/// <summary>
		/// Returns a string that represents the current CAML node.
		/// </summary>
		/// <returns>A string representation of the CAML node.</returns>
		public override string ToCaml()
		{
			return String.Format(CamlFormat, this.CamlType, (Value) ? "1" : "0");
		}


		/// <summary>
		/// Gets a <c>true</c> CAML boolean value.
		/// </summary>
		/// <value>A CAML value representing <c>true</c>.</value>
		public static CamlBooleanValue True
		{
			get { return new CamlBooleanValue(true); }
		}


		/// <summary>
		/// Gets a <c>false</c> CAML boolean value.
		/// </summary>
		/// <value>A CAML value representing <c>false</c>.</value>
		public static CamlBooleanValue False
		{
			get { return new CamlBooleanValue(false); }
		}
	}
}